﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using PlayDeezGames.Common;
using ASCII.Common;

namespace ASCII.ClickTheYellowBox
{
    public class CTYBInstructionsState : CTYBStateBase
    {

        public CTYBInstructionsState(ASCIIRenderer theRenderer)
            : base(theRenderer)
        {           
        }


        protected override void OnStart()
        {
            Renderer.SetCells(0, 0, Renderer.GridBoard.Columns, Renderer.GridBoard.Rows, 0, ASCIICellColor.Black, ASCIICellColor.Black);
            Renderer.DrawTable(TableDrawingPalette.V2H2Palette, new int[] { 0, Renderer.GridBoard.Columns - 1 }, new int[] { 0,2, Renderer.GridBoard.Rows - 1 }, ASCIICellColor.Blue, ASCIICellColor.DarkGray, false);
            Renderer.WriteText(1, 1, "  How to Play \"Click the Yellow Box\"  ", ASCIICellColor.White, ASCIICellColor.DarkGray);
            Renderer.WriteText(1, 4, "Really?", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(9, 4, "*REALLY*?!?", ASCIICellColor.Magenta, ASCIICellColor.Black);
            Renderer.WriteText(1, 6, "Very well.  In order to play this game", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 7, "you need to click a yellow box ( )", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(33, 7, "\u00DB", ASCIICellColor.Yellow, ASCIICellColor.Black);
            Renderer.WriteText(1, 8, "with your mouse as many times as you", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 9, "can in    seconds.  Each hit is worth", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(8, 9, "60", ASCIICellColor.Cyan, ASCIICellColor.Black);
            Renderer.WriteText(1, 10, "   points. Each miss costs    points.", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 10, "10", ASCIICellColor.Green, ASCIICellColor.Black);
            Renderer.WriteText(28, 10, "15", ASCIICellColor.Red, ASCIICellColor.Black);
            Renderer.WriteText(1, 12, "Certain other characters will give", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 13,"bonuses or penalties when you click", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 14,"on them.", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 16, "If you are looking for a list of what", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 17, "the characters are and what they do,", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 18, "you are looking in the wrong place.", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 20, "Part of the fun of a game is the fun", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 21, "of discovery, don't you think? At ", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 22, "least I think so.", ASCIICellColor.Gray, ASCIICellColor.Black);
            Renderer.WriteText(1, 24, "Good luck, and God bless.", ASCIICellColor.Cyan, ASCIICellColor.Black);
            Renderer.WriteText(1, 28, "      Click anywhere to go back.", ASCIICellColor.Green, ASCIICellColor.Black);
        }

        protected override void OnIdle()
        {
            
        }

        protected override void OnFinish()
        {
             
        }

        private void OnDraw()
        {
            Renderer.Render();
        }

        public override bool OnMessage(MessageBase theMessage)
        {
            if (theMessage.MessageId == CTYBStateMachine.MSGID_MouseUp)
            {
                ExitState = CTYBState.Title;
                Finish();
                return true;
            }
            else if (theMessage.MessageId == CTYBStateMachine.MSGID_Draw)
            {
                OnDraw();
                return true;
            }
            else
            {
                return base.OnMessage(theMessage);
            }
        }
    }
}
